package com.buss.purchase.service;

import java.util.Date;
import java.util.List;

import javax.persistence.PersistenceException;

import org.apache.cxf.BusException;

import com.buss.core.dic.CheckStatus;
import com.buss.core.exception.ServiceException;
import com.buss.core.persistence.OrderBy;
import com.buss.core.persistence.Paginalbe;
import com.buss.core.persistence.ResultList;
import com.buss.purchase.model.PurchaseOrderDetail;
import com.buss.purchase.model.PurchaseOrderMaster;

/**
 * 采购订单Service
 * @author gykl
 *
 */
public interface PurchaseOrderService {

	/**
	 * 保存采购订单信息
	 * @param master
	 * @return
	 * @throws PersistenceException
	 */
	public PurchaseOrderMaster saveOrderMaster(PurchaseOrderMaster master) throws PersistenceException;
	
	/**
	 * 修改采购订单信息
	 * @param master
	 * @throws PersistenceException
	 */
	public void editOrderMaster(PurchaseOrderMaster master,Long[] removeDetailIds) throws PersistenceException;
	
	/**
	 * 删除指定采购订单信息
	 * @param ids
	 */
	public void removeOrderMaster(Long id) throws ServiceException;
	
	/**
	 * 根据ID获取采购订单信息
	 * @param id
	 * @return
	 */
	public PurchaseOrderMaster loadOrderMaster(Long id);
	
	/**
	 * 根据单位编码和订单号获取采购订单信息
	 * @param companyId
	 * @param orderNumber
	 * @return
	 */
	public PurchaseOrderMaster loadOrderMaster(String companyId,String orderNumber);
	
	/**
	 * 更新当前审核状态
	 * @param id
	 * @param status
	 * @param checkUserId
	 * @param checkUserName
	 * @param checkDate
	 */
	public void updateCheckStatus(Long id,CheckStatus status,Long checkUserId,
			String checkUserName,Date checkDate);
	
	/**
	 * 查询采购订单信息列表
	 * @param companyId	单位编码
	 * @param branchId	库房编码
	 * @param salesManId	销售员编码
	 * @param orderStartDate	采购订单开始日期
	 * @param orderEndDate		采购订单结束日期
	 * @param checkStatus	审核状态
	 * @param checkUserId	审核员ID
	 * @param checkStartDate	审核开始时间
	 * @param checkEndDate	审核结束时间
	 * @param createUserId	录入员ID
	 * @param createStartDate	录入开始时间
	 * @param createEndDate	录入接收时间
	 * @return
	 */
	public ResultList<PurchaseOrderMaster> queryOrderMaster(String companyId,Long supplierId,Long branchId,
			Long salesManId,Date orderStartDate,Date orderEndDate,CheckStatus checkStatus,
			Long checkUserId,Date checkStartDate,Date checkEndDate,Long createUserId,
			Date createStartDate,Date createEndDate,Paginalbe page,OrderBy orderBy);
	
	
	/**
	 * 保存订单明细信息
	 * @param detail
	 */
	public void saveOrderDetail(PurchaseOrderDetail detail);
	
	/**
	 * 修改订单明细信息
	 * @param detail
	 */
	public void editOrderDetail(PurchaseOrderDetail detail);
	
	/**
	 * 保存订单明细信息
	 * @param orderDetails
	 */
	public void saveOrderDetails(List<PurchaseOrderDetail> orderDetails);
	
	/**
	 * 修改订单明细信息
	 * @param orderDetails
	 */
	public void editOrderDetails(List<PurchaseOrderDetail> orderDetails);
	
	/**
	 * 删除指定订单明细信息
	 * @param ids
	 */
	public void removeOrderDetail(Long[] ids);
	
	/**
	 * 根据采购订单ID、商品类别、商品编码获取采购订单明细信息
	 * @param masterId	采购订单ID
	 * @param categoryId	商品类别ID
	 * @param goodsId	商品ID
	 * @return
	 */
	public ResultList<PurchaseOrderDetail> queryOrderDetail(Long masterId,Long categoryId,Long goodsId, Paginalbe page);
}
